﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using System.Timers;
using Microsoft.TeamFoundation.VersionControl.Client;
using Microsoft.TeamFoundation.Client;
using System.IO;

namespace TFSAutoNotify.WindowsService
{
    public partial class TFSAutoNotify : ServiceBase
    {
        static int i = 0;
        System.Timers.Timer timesDo = new System.Timers.Timer(10*1000);
        public TFSAutoNotify()
        {
            InitializeComponent();
        }

        protected override void OnStart(string[] args)
        {
            AutoNotify.WriteLog("Start");
            timesDo.Interval = 10000;
            timesDo.Elapsed += new System.Timers.ElapsedEventHandler(OnTimedEvent);
            timesDo.AutoReset = true;
            timesDo.Enabled = true;
            AutoNotify.WriteLog("Tim");
            timesDo.Start();
            AutoNotify.WriteLog("time ");
            GC.KeepAlive(timesDo);
        }
        private void OnTimedEvent(object source, ElapsedEventArgs e)
        {         
           AutoNotify.Notify();
            i = i+1;

            AutoNotify.WriteLog(i.ToString());
        }
        protected override void OnStop()
        {
        }
     
    }
}
